package com.cooriproject.basemanage.service.serviceImpl;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.cooriproject.basemanage.entity.User;
import com.cooriproject.basemanage.mapper.UserMapper;
import com.cooriproject.basemanage.service.UserService;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{

    @Resource
    private UserMapper userMapper;

    @Override
    public int insertSelective(User record) {
        if (registervail(record.getUserName()).isEmpty()) {
            return userMapper.insertSelective(record);
        } else {
            return -1;
        }
    }

    @Override
    public List<User> selectByPrimaryKey(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public List<User> selectByUserNameAndUserPwd(String userName, String userPwd) {
        return userMapper.selectByUserNameAndUserPwd(userName, userPwd);
    }

    @Override
    public List<User> registervail(String userName){
        return userMapper.registervail(userName);
    }

    @Override
    public List<User> selectAll(){return userMapper.selectAll(); }

    @Override
    public int updatepwdByUserName(String userName,String userPwd){
        return userMapper.updatepwdByUserName(userName,userPwd);
    }

    @Override
    public int updatetypeByPrimaryKey(Integer userId, Integer userType) {
        return userMapper.updatetypeByPrimaryKey(userId,userType);
    }

    @Override
    public int updateUserInfo_user(String userPwd,Integer userId,String userRealname, String userTel, String userMail, Integer userDepart) {
        return userMapper.updateUserInfo_user(userPwd,userId,userRealname, userTel, userMail, userDepart);
    }

    @Override
    public int deleteByPrimaryKey(Integer userId) {
        return userMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public List<User> selectAllByUserId(Integer userId) {
        return userMapper.selectAllByUserId(userId);
    }
}
